#include "dosfunctor.h"

const string DoSFunctor::haydocksymbol = "HaydockMethod";
const string DoSFunctor::directsymbol = "DirectMethod";
const string DoSFunctor::methodsymbol = "Method";

DoSFunctor::DoSFunctor(System* s, const rule::list &opts) : approxDoSFunc(s,opts), method(defaultmethod)
{
	const size_t rulesize = opts.size();
	for(size_t r = 0; r < rulesize; r++)
	{
		if(!opts[r].first.isSymbolType())
			continue;
		
		symbol sym = opts[r].first.toSymbol();
		variant var = opts[r].second;
		
		if(sym.name() == methodsymbol && var.isSymbolType() && var.toSymbol().getType() == symbol::predefined && var.toSymbol().reference() == symbol::automatic)
		{
			method = defaultmethod;
		}
		else if(sym.name() == methodsymbol && var.isStringType())
		{
			if(var.toString() == haydocksymbol)
				method = haydockmethod;
			else if(var.toString() == directsymbol)
				method = directmethod;
		}
	}
}

complex DoSFunctor::getGreensFunctionValue(int id, complex energy)
{
	if(method == haydockmethod || method == defaultmethod)
		return approxDoSFunc.getGreensFunctionValue(id,energy);

	return 0;
}

double DoSFunctor::getDoSValue(int id, double energy)
{
	if(method == haydockmethod || method == defaultmethod)
		return approxDoSFunc.getDoSValue(id,energy);

	return 0;
}

arma::mat DoSFunctor::getDoS(int id, numeric::range energies)
{
	if(method == haydockmethod || method == defaultmethod)
		return approxDoSFunc.getDoS(id,energies);

	return arma::mat();
}